var express = require('express');
var app = express();

app.get('/', function(req, res) {
  res.type('text/plain');
  var retval = {
    "string": "Hello World"
  }
  res.send(retval);
});

// 银行名称
app.get('/api/v1/bankcard/issuebank/:bankname', function(req, res) {
  res.type('text/plain');
  var retval = {
    "bankname": req.params.bankname
  }
  res.send(retval);
});

// 银行卡号
app.get('/api/v1/bankcard/cardnumber/:cardnumber', function(req, res) {
  var cardnumber = req.params.cardnumber;
  var retval = {
    "bankname": '',
    'error_msg': '无法识别银行卡，仅支持abc银行',
    "result": false
  }
  
  res.type('text/plain');
  if (cardnumber.startsWith('1')) {
    retval = {"bankname": '工商银行', 'result': true}
  }else if (cardnumber.startsWith('2')) {
    retval = {"bankname": '建设银行', 'result': true}
  }

  res.send(retval);
});



app.listen(process.env.PORT || 4730);